package com.minivision.fdiot.entity;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Transient;
import org.springframework.data.redis.core.RedisHash;
import org.springframework.data.redis.core.index.Indexed;

import com.fasterxml.jackson.annotation.JsonIgnore;

import io.swagger.annotations.ApiModelProperty;

//Define and pin keyspaces via `@RedisHash("{yourkeyspace}") to specific slots when using Redis cluster
@RedisHash("facesets")
@Getter
@Setter
public class FaceSet implements Serializable {

	private static final long serialVersionUID = 6298659607552057753L;

	@Id
	@ApiModelProperty(value = "人脸库Token")
	private String facesetToken;
	@Indexed
	@ApiModelProperty(value = "自定义的人脸库唯一标识")
	private String outerId;
	@ApiModelProperty(value = "人脸库名称")
	private String displayName;
	@JsonIgnore
	@ApiModelProperty(value = "人脸库所有者")
	private String owner;

	@JsonIgnore
	@Transient
	@ApiModelProperty(value = "人脸列表")
	private List<Face> faces;
	
	@ApiModelProperty(value = "人脸库容量")
	private int capacity = Integer.MAX_VALUE;
	
	@ApiModelProperty(value = "人脸库优先级，值小为高")
	private int priority = 0;
	@ApiModelProperty(value = "人脸库阈值")
	private float threshold = 0.0f;

	@Indexed
	@ApiModelProperty(value = "应用标识")
    private String appKey;

	@ApiModelProperty(value = "扩展字段")
	private Map<String,String> extendMap;

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((facesetToken == null) ? 0 : facesetToken.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		FaceSet other = (FaceSet) obj;
		if (facesetToken == null) {
			if (other.facesetToken != null)
				return false;
		} else if (!facesetToken.equals(other.facesetToken))
			return false;
		return true;
	}

}
